package com.yxjx.duoxue;

import com.yxjx.duoxue.datamodel.DMActivity;
import com.yxjx.duoxue.datamodel.DMAdItem;
import com.yxjx.duoxue.datamodel.course.DMCourse;
import com.yxjx.duoxue.utils.UIHelper;

public class ShareTextHelper {
	
	/**
	 * 生成分享的文案
	 * @param course
	 * @return
	 */
	public static String getShareText(Object shareObject) {
		if (shareObject instanceof DMCourse) {
			DMCourse course = (DMCourse) shareObject;
			if (course.getSupportBook() == 1) {
				StringBuilder builder = new StringBuilder();
				builder.append("免费试听来啦，快来多学预约试听");
				builder.append(course.getSchoolFullName());
				builder.append("的");
				builder.append(course.getCourseName());
				return builder.toString();
			} else {
				StringBuilder builder = new StringBuilder();
				builder.append("孩子素质如何提升？快来多学看看");
				builder.append(course.getSchoolFullName());
				builder.append("的");
				builder.append(course.getCourseName());
				return builder.toString();
			}
		} else if (shareObject instanceof DMActivity) {
			DMActivity activity = (DMActivity) shareObject;
			StringBuilder builder = new StringBuilder();
			builder.append(activity.getActivityName());
			return builder.toString();
		} else if (shareObject instanceof DMAdItem) {
			DMAdItem ad = (DMAdItem) shareObject;
			return UIHelper.isEmpty(ad.getDes()) ? ad.getTitle() : ad.getDes() ;
		}
		return "多学为您的孩子推荐精选的兴趣课程和活动！";
	}
	
	/**
	 * generate shared image url
	 * @param shareObject
	 * @return
	 */
	public static String getShareImageUrl(Object shareObject) {
		if (shareObject instanceof DMCourse) {
			DMCourse course = (DMCourse) shareObject;
			return course.getHeadImageUrl();
		} else if (shareObject instanceof DMActivity) {
			DMActivity activity = (DMActivity) shareObject;
			return activity.getHeadImageUrl();
		} else if (shareObject instanceof DMAdItem) {
			DMAdItem ad = (DMAdItem) shareObject;
			return ad.getImageUrl();
		}
		return "";
	}
	
}
